package com.dating.view;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.dating.activity.R;

public class DtSuggestHer extends LinearLayout {
	Context _context;
	TextView tv_name;
	ImageView im_avatar,im_status;
	boolean _status = false;

	LayoutInflater inflater = null;

	public DtSuggestHer(Context context) {
		super(context);
		init(context, false, "Unknown", null);
	}

	public DtSuggestHer(Context context, boolean status, String name,
			Bitmap avatar) {
		super(context);
		init(context, status, name, avatar);
	}

	public void init(Context context, boolean status, String name, Bitmap avatar) {
		inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		inflater.inflate(R.layout.item_people, this);

		tv_name = (TextView) findViewById(R.id.tv_name);
		im_avatar = (ImageView) findViewById(R.id.im_avatar);
		im_status=(ImageView)findViewById(R.id.im_status);

		setStatus(status);
		setName(name);
		setAvatar(avatar);
	}

	public void setStatus(boolean status) {
		_status = status;
		if(_status){
			tv_name.setBackgroundResource(R.color.aaaa);
			tv_name.setTypeface(null,Typeface.BOLD);
			tv_name.setTextColor(super.getContext().getResources().getColor(R.color.yellow));
			im_status.setVisibility(View.VISIBLE);
		}else{
			tv_name.setBackgroundResource(R.color.aaaa);
			tv_name.setTypeface(null,Typeface.NORMAL);
			tv_name.setTextColor(super.getContext().getResources().getColor(R.color.white));
			im_status.setVisibility(View.INVISIBLE);
		}
	}

	public void setName(String name) {
		tv_name.setText(name);
	}

	public void setAvatar(Bitmap avatar) {
		if (avatar == null) {
			im_avatar.setImageResource(R.drawable.noavatar);
			return;
		}
		im_avatar.setImageBitmap(avatar);
	}
}
